﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;

public partial class template_thong_tin_du_an : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            int pageIndex = ConvertUtility.ToInt32(Request.QueryString["page"]);
            int catID = ConvertUtility.ToInt32(Request.QueryString["catID"]);
            if (catID > 0)
            {
                if (pageIndex > 0)
                {
                    bindDA(catID,pageIndex);
                    hidPageIndex.Value = pageIndex.ToString();
                }
                else
                {
                    bindDA(catID,1);
                    hidPageIndex.Value = "1";
                }
            }
        }
        catch (Exception ex) { }
    }
    protected void bindDA(int catID,int pageIndex)
    {
        string lstCatID = ConvertUtility.ToString(Request.QueryString["lstCatID"]);
        int phanLoaiID=0;
        if (!String.IsNullOrEmpty(lstCatID))
        {
            phanLoaiID =ConvertUtility.ToInt32(lstCatID.Substring(0, lstCatID.Length - 1));
        }

        Content_Info[] lstContent = Content_Info.searchNews(catID, phanLoaiID);

        repListContent.DataSource = lstContent.Skip((pageIndex - 1) * 12).Take(12);
        repListContent.DataBind();

        int totalPage = (int)Math.Ceiling(ConvertUtility.ToDouble(lstContent.Length) / 12);
        pagerbot.Text = ConvertUtility.buildSimplePaging(totalPage, pageIndex);

    }
}